# -*- coding: utf-8 -*-
"""
created on 2017/12/8 10:09

@author: didichen
"""

# 开始url：http://www.pythonchallenge.com/pc/return/5808.html
# 结束url：http://www.pythonchallenge.com/pc/return/evil.html

import requests
from PIL import Image

img = Image.open('cave.jpg')
w, h = img.size
print(w, h)

img_list = [Image.new(img.mode, size=(w // 2, h // 2)) for i in range(4)]
# img_list = [Image.new(img.mode, size=(w // 2, h // 2)) ]* 4 这种方式是错的~~~
img_pixel_list = [item.load() for item in img_list]

for i in range(0, w, 2):
    for j in range(0, h, 2):
        img_pixel_list[0][(i / 2, j / 2)] = img.getpixel((i, j))
        img_pixel_list[1][(i / 2, j / 2)] = img.getpixel((i, j + 1))
        img_pixel_list[2][(i / 2, j / 2)] = img.getpixel((i + 1, j))
        img_pixel_list[3][(i / 2, j / 2)] = img.getpixel((i + 1, j + 1))
#
for i in range(0,4):
    img_list[i].show()

